﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for UIHelper
/// </summary>
public class UIHelper
{
    public UIHelper()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public static string GetVideoUrl(string videoId)
    {
        var url = string.Empty;

        var strConn = ConfigurationManager.ConnectionStrings["dbsGetUserInfo"].ConnectionString;
        var sqlConn = new SqlConnection(strConn);
        string selectSql = "select URL from VideoUrl where UrlCode = @UrlCode";

        var command = new SqlCommand(selectSql, sqlConn);
        command.CommandType = CommandType.Text;
        command.Parameters.AddWithValue("@UrlCode", videoId);

        DataTable dt = new DataTable();
        var da = new SqlDataAdapter(command);
        da.Fill(dt);

        if (dt.Rows.Count > 0)
        {
            url = dt.Rows[0]["URL"].ToString();
        }

        return url;
    }
}